package com.feixiang.springbootinit.model.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
/**
 * 会话存档消息类型枚举
 */
public enum SessionArchiveMsgTypeEnum {

    TEXT("text", "文本"),

    IMAGE("image", "图片"),

    REVOKE("revoke", "撤回"),

    AGREE("agree", "同意"),

    DISAGREE("disagree", "不同意"),

    VOICE("voice", "语音"),

    VIDEO("video", "视频"),

    CARD("card", "名片"),

    LOCATION("location", "位置"),

    EMOTION("emotion", "表情"),

    FILE("file", "文件"),//

    LINK("link", "链接"),

    WEAPP("weapp", "小程序"),

    CHATRECORD("chatrecord", "会话记录"),

    TODO("todo", "待办"),

    VOTE("vote", "投票"),

    COLLECT("collect", "填表"),

    REDPACKET("redpacket", "红包"),

    MEETING("meeting", "会议邀请"),

    MEETING_NOTIFICATION("meeting_notification", "会议控制"),

    DOCMSG("docmsg", "在线文档"),

    MARKDOWN("markdown", "MarkDown"),

    NEWS("news", "图文"),

    CALENDAR("calendar", "日程"),

    MIXED("mixed", "混合类型"),

    MEETING_VOICE_CALL("meeting_voice_call", "音频存档"),

    VOIP_DOC_SHARE("voip_doc_share", "音频共享文档"),

    EXTERNAL_REDPACKET("external_redpacket", "互通红包"),

    SPHFEED("sphfeed", "视频号"),

    VOIPTEXT("voiptext", "音视频通话"),

    QYDISKFILE("qydiskfile", "微盘文件"),

    UNKNOWN("unknown", "未知"),
    ;

    private String code;

    private String msg;

    public static String getNameByCode(String code) {
        SessionArchiveMsgTypeEnum[] enums = SessionArchiveMsgTypeEnum.values();
        for (int i = 0; i < enums.length; i++) {
            SessionArchiveMsgTypeEnum anEnum = enums[i];
            if (anEnum.getCode().equalsIgnoreCase(code)) {
                return anEnum.getMsg();
            }
        }
        return null;
    }

    /**
     * 从字符串转换为 SessionArchiveMsgTypeEnum 枚举值
     *
     * @param type 字符串类型
      * @return 对应的 SessionArchiveMsgTypeEnum 枚举值
     */
    public static SessionArchiveMsgTypeEnum fromString(String type) {
        for (SessionArchiveMsgTypeEnum msgType : SessionArchiveMsgTypeEnum.values()) {
            if (msgType.code.equalsIgnoreCase(type)) {
                return msgType;
            }
        }
        return UNKNOWN;
    }
}
